- /* sffbntbl.cpp by K.Tsuru */
- // function ID 7101 DRADIX
- /************************************************
- SFraction class
- It provodes the table of Bernoulli's numbers B[n].
- *************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- void BernNumTable(SNBlock <SFraction>& Bn, uint N){
- SNBlock <SInteger> t(2u*N+1);
- Bn.reserve(N);
- int err = (t.Error() != t.NORMAL) || (Bn.Error() != Bn.NORMAL);
- if(err) t[0].SetError(t[0].OUT_OF_RANGE,"BernNumTable", 7101);
-
- uint i, n;
- SInteger q, b1, b2, d;
- SLong B1, B2;
-
-
- for(i = 0; i <= 2*N; i++) t[i].SetZero();
- q = 1; t[1] = 1;
- for(n = 2; n <= 2*N; n++){
- for(i = 1; i< n; i++) IsMult(t[i], i, t[i-1]);
- t[n-1].SetZero();
- for(i = n; i >= 2; i--) IIAdd(t[i], t[i-2], t[i]);
- if(n % 2 == 0){
- IsMult(q, 4, q); // q *= 4;
- IsSub(q, 1, d);
- b2 = q*d; // b2 = q*(q-1);
- IsMult(t[0], n, b1);
- B1 = b1.ConvToDec();
- B2 = b2.ConvToDec(); // radix conversion
- Bn[n/2].Set(B1, B2);
- Bn[n/2].Reduce();
- }
- }
- }
sffbntbl.cpp : last modifiled at 2015/12/04 10:36:15(1,047 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2016/09/13 19:56:38 (Tue Sep 13 19:56:38 2016).